<template>
  <div class="login">
    <el-dialog
      title="登 录"
      :visible="true"
      width="400px"
      :modal="false"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :show-close="false"
      center
      class="login"
    >
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="用户名">
          <el-input v-model="form.username"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="form.psw" show-password></el-input>
        </el-form-item>
        <el-form-item style="text-align:right">
          <el-button type="primary" @click="OnLogin" :loading="btnloading">
            确 定
          </el-button>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <p />
        @北京-没想好
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { System1 } from "@/api";
export default {
  data() {
    return {
      form: { username: "", psw: "" },
      btnloading: false
    };
  },
  //外部属性
  props: {},
  //内部方法
  methods: {
    initPage() {},
    async OnLogin() {
      this.btnloading = true;
      let res = await System1.Login(this.form);
      res.strMS && this.$message(res.strMS);
      if (res.MsRbool) {
        this.$store.dispatch("User/setTokenData", res.data).then(() => {
          this.$router.push("/Home");
        });
      } else {
        this.btnloading = false;
      }
    }
  },
  //组件
  components: {},
  //初始化 异步加async await
  mounted() {
    this.initPage();
  },
  //计算属性
  computed: {},
  //监视
  watch: {}
};
</script>

<style>
.login {
  background-color: #545c64;
}
</style>
